package com.ruoyi.common.translation.core.impl;

import com.ruoyi.common.translation.annotation.TranslationType;
import com.ruoyi.common.translation.constant.TransConstant;
import com.ruoyi.common.translation.core.TranslationInterface;
import com.ruoyi.common.translation.core.TranslationService;
import lombok.AllArgsConstructor;

/**
 * 用户名翻译实现
 *
 * @author zhengyz
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.USER_ID_TO_NAME)
public class UserNameTranslationImpl implements TranslationInterface<String> {

    private final TranslationService userService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof Number id) {
            return userService.userIdsToUserName(id.toString());
        } else if (key instanceof String ids) {
            return userService.userIdsToUserName(ids);
        }
        return null;
    }
}
